<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<script>
			var  timer;
			function showTime(){
				var d=new Date();
				// alert(d.toLocaleString());
				// alert("UTC:"+d.toUTCString());
				document.getElementById("time").innerHTML=d.toLocaleString();
			}
			function setTimer(){
				showTime();//先执行一次
				timer=window.setInterval("showTime()",1000);
			}
			function stopTime(){
				window.clearInterval(timer);
			}
		</script>
	</head>
	<body onload="setTimer()">
		<h2 id="time"></h2> 
		<input type="button" value="停" onclick="stopTime()"/>
	</body>
</html>
